<template>
  <div class="benefits-section">
    <div class="section-header">
      <span class="section-tag">小谷粒福利</span>
    </div>
    
    <div class="benefits-grid">
      <div
        v-for="(benefit, index) in benefits"
        :key="index"
        class="benefit-card"
        @click="handleBenefitClick(benefit, index)"
      >
        <div class="benefit-image">
          <img :src="benefit.img" :alt="`福利${index + 1}`" />
          <div class="benefit-overlay">
            <div class="benefit-icon">🎁</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ElMessage } from 'element-plus'

const props = defineProps({
  benefits: {
    type: Array,
    default: () => []
  }
})

const handleBenefitClick = (benefit, index) => {
  ElMessage.success(`领取福利${index + 1}`)
  console.log('福利点击:', benefit)
}
</script>

<style scoped>
.benefits-section {
  padding: 0 16px 20px;
}

.section-header {
  margin-bottom: 16px;
}

.section-tag {
  display: inline-block;
  background: linear-gradient(135deg, #4CAF50 0%, #8BC34A 100%);
  color: white;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.benefits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.benefit-card {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.benefit-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.benefit-image {
  position: relative;
  width: 100%;
  height: 120px;
  overflow: hidden;
}

.benefit-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.benefit-card:hover .benefit-image img {
  transform: scale(1.05);
}

.benefit-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    45deg,
    rgba(76, 175, 80, 0.8) 0%,
    rgba(139, 195, 74, 0.6) 100%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.benefit-card:hover .benefit-overlay {
  opacity: 1;
}

.benefit-icon {
  font-size: 24px;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-8px);
  }
  60% {
    transform: translateY(-4px);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .benefits-section {
    padding: 0 12px 16px;
  }
  
  .benefits-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
  }
  
  .benefit-image {
    height: 100px;
  }
  
  .section-tag {
    padding: 4px 10px;
    font-size: 11px;
  }
  
  .benefit-icon {
    font-size: 20px;
  }
}
</style>
